#Definition of user redix
radix define B_bus_state {
16'b0000000000000000 "---",
16'b0000000000000001 "MDR",
16'b0000000000000010 "PC",
16'b0000000000000100 "MBR",
16'b0000000000001000 "MBR0",
16'b0000000000010000 "SP",
16'b0000000000100000 "LV",
16'b0000000001000000 "CPP",
16'b0000000010000000 "TOS",
16'b0000000100000000 "OPC",
16'b0000001000000000 "none",
16'b0000010000000000 "none",
16'b0000100000000000 "none",
16'b0001000000000000 "none",
16'b0010000000000000 "none",
16'b0100000000000000 "none",
16'b1000000000000000 "none"
-default hex
}

#Test Name "Main1" ref. to Structured Computer Organization p. 262

# INITIALIZE SIGNALS
add wave -noupdate -divider "CLOCK"
# Add clock
add wave -noupdate -label "Clock" {sim:/top_level/clk_in }
# define clock to 20 ns
force -freeze {sim:/top_level/clk_in} 1 0, 0 {10 ns} -r 20ns  

add wave -noupdate -divider "BUSES"
# Add Bbus & set radix to dec
add wave -noupdate -radix decimal -label "B-BUS" {sim:/top_level/bbus }         
#property wave -radix decimal "B-BUS"
# Add Cbus & set radix to dec
add wave -noupdate -radix decimal -label "C-BUS" {sim:/top_level/cbus }         
#property wave -radix decimal "C-BUS"


add wave -noupdate -divider "REGISTERS"
# Add SP-register & set radix to dec
add wave -noupdate -radix decimal -label "MAR" {sim:/top_level/mar/content }   
#property wave -radix decimal "MAR"
add wave -noupdate -radix decimal -label "MDR" {sim:/top_level/mdr/content }   
#property wave -radix decimal "MDR"
add wave -noupdate -label "PC" -radix decimal {sim:/top_level/pc/content }   
#property wave -radix decimal "PC"
add wave -noupdate -label "SP" -radix decimal {sim:/top_level/sp/content }   
#property wave -radix decimal "SP"
add wave -noupdate -label "LV" -radix decimal {sim:/top_level/lv/content }   
#property wave -radix decimal "LV"
add wave -noupdate -label "CPP" -radix decimal {sim:/top_level/cpp/content }   
#property wave -radix decimal "CPP"
add wave -noupdate -label "TOS" -radix decimal {sim:/top_level/tos/content }   
#property wave -radix decimal "TOS"
add wave -noupdate -label "OPC" -radix decimal {sim:/top_level/opc/content }   
#property wave -radix decimal "OPC"
add wave -noupdate -label "H" -radix decimal {sim:/top_level/h/content }   
#property wave -radix decimal "H"
add wave -noupdate -label "MBR" -radix hexadecimal {sim:/top_level/MBR/content }


add wave -noupdate -divider "READ-ENABLE controls"
# Add read-enable (SP-register)
add wave -noupdate -label "B-bus Select" -radix B_bus_state {sim:/top_level/BselDemux}

add wave -noupdate -divider "============== "
add wave -noupdate -divider "MIR"

add wave -noupdate -label "Addr (MIR 35n-27)" -radix hex {sim:/top_level/MicroProgramAddr}

add wave -noupdate -divider "J (Jump-selection)"
add wave -noupdate -label "JMPC (MIR 26)" {sim:/top_level/JMPC }    
add wave -noupdate -label "JAMN (MIR 25)" {sim:/top_level/JAMN }       
add wave -noupdate -label "JAMZ (MIR 24)" {sim:/top_level/JAMZ }    

add wave -noupdate -divider "ALU (ALU-operations)"
add wave -noupdate -label "SLL8 (MIR 23)" {sim:/top_level/SLL8 }    
add wave -noupdate -label "SRA1 (MIR 22)" {sim:/top_level/SRA1 }       
add wave -noupdate -label "F0 (MIR 21)" {sim:/top_level/F0 }    
add wave -noupdate -label "F1 (MIR 20)" {sim:/top_level/F1 }    
add wave -noupdate -label "ENA (MIR 19)" {sim:/top_level/ENA }       
add wave -noupdate -label "ENB (MIR 18)" {sim:/top_level/ENB }    
add wave -noupdate -label "INVA (MIR 17)" {sim:/top_level/INVA }       
add wave -noupdate -label "INC (MIR 16)" {sim:/top_level/INC }    

add wave -noupdate -divider "C (WRITE-ENABLE controls)"
add wave -noupdate -label "WE H (MIR 15)"   {sim:/top_level/select_h }
add wave -noupdate -label "WE OPC (MIR 14)" {sim:/top_level/select_opc }
add wave -noupdate -label "WE TOS (MIR 13)" {sim:/top_level/select_tos }    
add wave -noupdate -label "WE CPP (MIR 12)" {sim:/top_level/select_cpp }    
add wave -noupdate -label "WE LV (MIR 11)"  {sim:/top_level/select_lv }    
add wave -noupdate -label "WE SP (MIR 10)"  {sim:/top_level/select_sp }    
add wave -noupdate -label "WE PC (MIR 9)"  {sim:/top_level/select_pc }    
add wave -noupdate -label "WE MDR (MIR 8)" {sim:/top_level/select_mdr }    
add wave -noupdate -label "WE MAR (MIR 7)" {sim:/top_level/select_mar }    

add wave -noupdate -divider "M (Memory Control Signals)"
add wave -noupdate -label "wr (MIR 6)" {sim:/top_level/MIR(6) }    
add wave -noupdate -label "rd (MIR 5)" {sim:/top_level/MIR(5) }    
add wave -noupdate -label "fetch (MIR 4)" {sim:/top_level/MIR(4) }    

add wave -noupdate -divider "B (Register Read enable)"
#0 = MDR, 1 = PC, 2 = MBR, 3 = MBR0, 4 = SP, 5 = LV, 6 = CPP, 7 = TOS, 8 = TOS, 9-F = none
add wave -noupdate -label "B-bus 3 (MIR 3)" {sim:/top_level/MIR(3) }    
add wave -noupdate -label "B-bus 2 (MIR 2)" {sim:/top_level/MIR(2) }    
add wave -noupdate -label "B-bus 1 (MIR 1)" {sim:/top_level/MIR(1) }    
add wave -noupdate -label "B-bus 0 (MIR 0)" {sim:/top_level/MIR(0) }    
add wave -noupdate -divider "============== "
